<?php 
/**
  * @file This file handles user management
  * 
  */

require_once("security.php");
require("header.php");
require("admin_header.php");
?>
<script type="text/javascript">

var mydata = [<?php 
$res = mysql_query("select * from players order by charname;", $conn);
if (!$res)
	die("Problem with mysql: ".$message);

while($row = mysql_fetch_assoc($res))
	{
	echo("{charname:\"".$row['charname']."\", admin: \"".($row['admin'] ? "Yes" : "No")."\", bonus: \"".($row['bonus'] ? "Yes" : "No")."\"},");
	}
?>];

var lastsel; 

$(document).ready(function() { 
	$("#list").jqGrid({
    	data:mydata,
      	url:'example.php',
      	datatype: 'local',
      	mtype: 'GET',
      	colNames:['Character','Admin','Bonus'],
      	colModel :[ 
        	{name:'charname', index:'charname'}, 
        	{name:'admin', index:'admin', editable:true, edittype:"checkbox", editoptions: {value:"Yes:No"}}, 
        	{name:'bonus', index:'bonus', editable:true, edittype:"checkbox", editoptions: {value:"Yes:No"}}, 
      		],
      	pager: '#pager',
      	rowNum:20,
      	height: 'auto', 
      	width: 750,
      	rowList:[10,20,30],
      	sortname: 'charname',
      	sortorder: 'desc',
      	viewrecords: true,
      	caption: 'User Manager',
      	editurl: "server.php",
      	onSelectRow: function(id){ 
      		if(id && id!==lastsel)
          		{ 
          		jQuery('#list').jqGrid('restoreRow',lastsel); 
          		jQuery('#list').jqGrid('editRow', id, true); 
          		lastsel=id; 
          		} 
      		},           
    	}); 

	jQuery("#list").jqGrid('navGrid',"#pager",{edit:false,add:false,del:true}); 
	//jQuery("#list").jqGrid('editRow',"Drachs"); 
  	}); 


</script>

<table width=80%>
<tr><td>These users have logged into this system.   Admin users can access the admin pages.   Bonus users can request the loss bonus.
<center><br>

<table id="list"></table> 
<div id="pager"></div> 


<br><br><br>


</table>